<?php if(is_array($items) && !empty($items)){?>

<table class="calendar-news" cellpadding="0" cellspacing="0" >
<tr>
<?php
	// liczba rekordow
	$catsCnt = count($items);
	$columns = 1
?>
    	
    	
<?php foreach ($items as $k => $news) {?>		
		
<?php     	
        if(($k+1) % $columns == 0) { 
            echo "<td style=\"width:".(100/$columns)."%;text-align: left; \" align=\"left\" valign=\"top\">";
?>
		<table  class="hompage-one-news" width="100%" cellpadding="0" cellspacing="0"><tr><td width="60">
		<?php $thumb = $this->Html->url('/', true).str_replace(' ',"%20",$fileUpload->image($news['NewUpload']['name'],array('autoResize'=>true,'width'=>120,'imagePathOnly'=>true)));?>
		<?php echo $this->Html->link("&nbsp;", array('plugin'=>'calendar','controller'=>'news','action' => 'view', $news['News']['id'],Inflector::slug($news['News']['name'],'-')),array('escape'=>false,'class'=>"highslide", 'title'=>$news['News']['name'], 'style'=>"background: url(".$thumb.") center no-repeat;")); ?>    	
		</td><td valign="top"  class="news-content">
    	<strong class="homepage-news-title"><?php echo nl2br($news['News']['name'])?></strong><br/>
    	<span class="homepage-news-content">
    	<?php $content = $this->Text->truncate(
			    $news['News']['small_content'],
			    100,
			    array(
			        'ending' => '...',
			        'exact' => false
			    ));?>
    	<?php echo nl2br($content)?></span><br/>
    	<?php echo $this->Html->link(__d('calendar','więcej...',true),array('plugin'=>'calendar','controller'=>'news','action'=>'view',$news['News']['id']),array('class'=>'link-more'));?>
        </td></tr></table>	
<?php       echo "</td></tr>"; 
            if ($k!=($catsCnt-1)) echo "<tr>"; 
        } else { 
            echo "<td style=\"width:".(100/$columns)."%;text-align: left; \" align=\"left\" valign=\"top\">";
?>
		<table class="hompage-one-news" width="100%" cellpadding="0" cellspacing="0"><tr><td width="60">
		<?php $thumb = $this->Html->url('/', true).str_replace(' ',"%20",$fileUpload->image($news['NewUpload']['name'],array('autoResize'=>true,'width'=>120,'imagePathOnly'=>true)));?>
		<?php echo $this->Html->link("&nbsp;", array('plugin'=>'calendar','controller'=>'news','action' => 'view', $news['News']['id'],Inflector::slug($news['News']['name'],'-')),array('escape'=>false,'class'=>"highslide", 'title'=>$news['News']['name'], 'style'=>"background: url(".$thumb.") center no-repeat;")); ?>
		
		    	
		</td><td valign="top" class="news-content">
    	<strong class="homepage-news-title"><?php echo nl2br($news['News']['name'])?></strong><br/>
    	<?php $content = $this->Text->truncate(
			    $news['News']['small_content'],
			    100,
			    array(
			        'ending' => '...',
			        'exact' => false
			    ));?>
    	<?php echo nl2br($content)?><br/>
    	<?php echo $this->Html->link(__d('calendar','więcej...',true),array('plugin'=>'calendar','controller'=>'news','action'=>'view',$news['News']['id']),array('class'=>'link-more'));?>
		 </td></tr></table>	
 
<?php             echo "</td>"; 
        } 
	}
    // uzupełnienie ostatniego rekordu
	$numSpaces = $columns - ($catsCnt % $columns); 
    if ($numSpaces!=0 && $numSpaces != $columns ) { 
        for ($j=0;$j<$numSpaces;$j++) { 
            echo "<td style=\"width:".(100/$columns)."%;\">&nbsp;</td>"; 
        } 
        echo "</tr>"; 
    }
?>
</table>

<?php }?>

<?php echo $html->link(__d('calendar','zobacz wszystkie...',true),array('plugin'=>'calendar','controller'=>'news','action'=>'display',1))?>

